package br.com.halyson.pontoeletronico.adapter;

import br.com.halyson.pontoeletronico.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MenuListAdapter extends BaseAdapter
{
    
    private Context context;
    
    private String[] title;
    
    private String[] subTitle;
    
    int[] icon;
    
    LayoutInflater inflater;
    
    public MenuListAdapter(Context context, String[] title, String[] subtitle, int[] icon)
    {
        this.context = context;
        this.title = title;
        this.subTitle = subtitle;
        this.icon = icon;
    }
    
    @Override
    public int getCount()
    {
        return title.length;
    }
    
    @Override
    public Object getItem(int position)
    {
        return title[position];
    }
    
    @Override
    public long getItemId(int position)
    {
        return position;
    }
    
    public View getView(int position, View convertView, ViewGroup parent)
    {
        TextView txtTitle;
        TextView txtSubTitle;
        ImageView imgIcon;
        
        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View itemView = inflater.inflate(R.layout.drawer_list_item, parent, false);
        
        txtTitle = (TextView) itemView.findViewById(R.id.title);
        txtSubTitle = (TextView) itemView.findViewById(R.id.subtitle);
        
        imgIcon = (ImageView) itemView.findViewById(R.id.icon);
        
        txtTitle.setText(title[position]);
        txtSubTitle.setText(subTitle[position]);
        
        imgIcon.setImageResource(icon[position]);
        
        return itemView;
    }
    
}